const date_ = require('../lib/util/date_');
const path = require('path');

// 当前项目根目录
const rootPath = path.normalize(path.join(''));
// 模板目录
const templatePath = path.normalize(path.join(__dirname, './template/fsd'));
// 项目根目录
const serverBasePath = 'E:\\work\\work-space\\big-data\\git\\local-repository\\feishu-server-code\\fsd-app-transition/';
const frontBasePath = 'E:\\work\\work-space\\loolink\\fsp/';

// 服务模块名称
const modelName = 'transition';
// api层项目源码包目录
const path_server_api = serverBasePath + `fsd-${modelName}-api/src/main/java/com/szewec/fsd/api`;
// provider层项目源码包目录
const path_server_service = serverBasePath + `fsd-${modelName}-service/src/main/java/com/szewec/fsd/service`;
// provider层项目Mapper源码包目录
const path_server_service_mapper = serverBasePath + `fsd-${modelName}-service/src/main/resources`;
// // web层项目源码包目录
const path_web = frontBasePath + 'fsp-web/src';

module.exports = {
    rootPath: rootPath,
    // 数据源配置
    datasource: {
        db_type : 'postgres',
        user: 'postgres', // 用户名
        // password: 'postgres', // 密码
        password: '123456', // 密码
        database: 'fsd-transition', // 数据库
        // host: '10.0.10.183', // host
        host: 'localhost', // host
        port: 5432, // 端口
        connectionLimit: 1, // 连接池的连接个数，默认为 1
        prefix: '', // 数据表前缀，如果一个数据库里有多个项目，那项目之间的数据表可以通过前缀来区分
    },
    // 作者信息配置
    authorInfo: {
        author: 'zyd',
        timestamp: date_.datetime(),
        copyright: 'Copyright © 2017 - 2020 zyd.All Rights Reserved'
    },
    // 策略配置
    strategy: {
        // 是否文件覆盖【true：覆盖；false：不覆盖】
        fileOverridable: true,
        // 是否驼峰转换【true：是；false：否】
        camelCase: true,
        // 项目名称（默认为空）
        project: '',
        // 模块名称（包名：cn.net.cfss.fgbp.api.pm）
        module: modelName,
        // 模板参数设定
        paramKey:[
            {
                key: 'module',
                disc: '模块',
                dynamic: true,
                value: function () {
                    return '';
                },
            },
            {
                key: 'submodule',
                disc: '子模块',
                dynamic: true,
                value: function () {
                    return '';
                },
            },
            {
                key: 'entitykey',
                disc: 'entityKey如: UserRole',
                dynamic: true,
                value: function () {
                    return '';
                },
            },
            {
                key: 'entityBeanName',
                disc: 'entityBeanName如: userRole',
                dynamic: true,
                value: function () {
                    return '';
                },
            },
            {
                key: 'entityNameLower',
                disc: 'entityNameLower如: userrole',
                dynamic: true,
                value: function () {
                    return '';
                },
            },
            {
                key: 'entityNameHyphen',
                disc: 'entityNameHyphen如: user-role',
                dynamic: true,
                value: function () {
                    return '';
                },
            },
            {
                key: 'table',
                disc: '表名: t_user',
                dynamic: true,
                value: function () {
                    return '';
                },
            },
            {
                key: 'model',
                disc: 'model层',
                dynamic: false,
                value: 'model',
            },
            {
                key: 'service',
                disc: 'service层',
                dynamic: false,
                value: 'service',
            },
            {
                key: 'controller',
                disc: 'controller层',
                dynamic: false,
                value: 'controller',
            },
        ],
        // 数据库表配置
        tableConfig:{
            // 表前缀（生成代码时去除前缀）
            prefix: '',
            // 是否有项目分隔
            projectSplit: false,
            // 是否模块分隔
            moduleSplit: false,
            // 分隔符
            separator: '_',
        },
        // 生成基础继承属性配置
        baseDtoConfig:{
            hasBaseDto: false,
            // 基类列
            baseColumns: ['create_by', 'create_time', 'update_by', 'update_time', 'del_flag'],
            // 删除列
            deleteColumn: 'del_flag'
        },
        // 自动填充字段值配置
        fieldFillConfig:{
            hasFieldFill: true,
            // 基类列
            insertFillColumns: ['create_time', 'del_flag', 'tenant_id'],
            insertUpdateFillColumns: ['update_time'],
            updateFillColumns: [],
        },
        // 生成基础继承属性配置
        rangeFieldConfig:{
            hasRangeField: true,
            // 基类列
            rangeFieldColumns: ['create_time', 'update_time'],
            // 删除列
            rangeFieldSuffixKey: 'Range'
        },
        feishuBiTableFieldConfig:{
            excludes: ["fid", "app_token", "table_id", "view_id", "record_id", "create_time", "update_time", "last_update_time", "del_flag"]
        },
        // 代码生成数据库扫表策略
        generateTable: {
            // 扫描以前缀开始的表
            tablePrefix : 'contract_',
            // 指定包含的表
            includes: [
                'contract_basis_info'
            ],
            // 排除指定的表（与includes互斥）
            excludes: [
            ],
        },
    },
    // 模板配置策略
    template_config : {
        // 模板引擎 默认不动
        engine: {
            autoescape: true,
            trimBlocks: false,
            lstripBlocks: false,
            tags:{
                blockStart: '[%',
                blockEnd: '%]',
                variableStart: '[[',
                variableEnd: ']]',
                commentStart: '[#',
                commentEnd: '#]'
            }
        },
        // 模板目录配置
        template: {
            templateRootPath: templatePath
        }

    },
    // 生成目标任务配置，可以根据情况自定义
    targets: {
        // api entity类
        api_entity: {
            // 是否强制覆盖
            overridable: true,
            // 生成根目录
            targetRoot: path_server_api,
            // 生成模块目录
            targetModule: '${module}',
            // 生成包名目录
            targetPackage: 'entity',
            // 文件名称
            fileName: '${entitykey}',
            // 文件类型
            fileType: 'java',
            // 文件名称前缀
            prefix: '',
            // 文件名称后缀
            suffix: '',
            // 指定模板文件
            template: 'server/api/entity.java',
            // 是否生效【true：生效可用，false：不可用】
            enable: true,
            // 是否静态模板（可忽略）
            statically: false,
            // 依赖描述（可忽略）
            dependencies: ['schema'],
        },
        api_vo: {
            overridable: false,
            targetRoot: path_server_api,
            targetModule: '${module}',
            targetPackage: 'vo',
            fileName: '${entitykey}DtoVo',
            fileType: 'java',
            prefix: '',
            suffix: '',
            template: 'server/api/vo.java',
            enable: true,
            statically: false,
            dependencies: ['schema'],
        },
        api_feign: {
            overridable: false,
            targetRoot: path_server_api,
            targetModule: '${module}',
            targetPackage: 'feign',
            fileName: '${entitykey}Feign',
            fileType: 'java',
            prefix: '',
            suffix: '',
            template: 'server/api/feign.java',
            enable: true,
            statically: false,
            dependencies: ['schema'],
        },
        service_service: {
            overridable: false,
            targetRoot: path_server_service,
            targetModule: '${module}',
            targetPackage: 'service',
            fileName: 'I${entitykey}Service',
            fileType: 'java',
            prefix: '',
            suffix: '',
            template: 'server/service/service.java',
            enable: true,
            statically: false,
            dependencies: ['schema'],
        },
        service_service_impl: {
            overridable: false,
            targetRoot: path_server_service,
            targetModule: '${module}',
            targetPackage: 'service/impl',
            fileName: '${entitykey}ServiceImpl',
            fileType: 'java',
            prefix: '',
            suffix: '',
            template: 'server/service/service.impl.java',
            enable: true,
            statically: false,
            dependencies: ['schema'],
        },
        service_mapper: {
            overridable: false,
            targetRoot: path_server_service,
            targetModule: '${module}',
            targetPackage: 'mapper',
            fileName: '${entitykey}Mapper',
            fileType: 'java',
            prefix: '',
            suffix: '',
            template: 'server/service/mapper.java',
            enable: true,
            statically: false,
            dependencies: ['schema'],
        },
        
        service_mapper_xml: {
            overridable: false,
            targetRoot: path_server_service_mapper,
            targetModule: '',
            targetPackage: 'mapper',
            fileName: '${entitykey}Mappper',
            fileType: 'xml',
            prefix: '',
            suffix: '',
            template: 'server/service/mapper.xml',
            enable: true,
            statically: false,
            dependencies: ['schema'],
        },
        service_controller: {
            overridable: false,
            targetRoot: path_server_service,
            targetModule: '${module}',
            targetPackage: 'controller',
            fileName: '${entitykey}Controller',
            fileType: 'java',
            prefix: '',
            suffix: '',
            template: 'server/service/controller.java',
            enable: true,
            statically: false,
            dependencies: ['schema'],
        },
        web_service_model: {
            overridable: false,
            targetRoot: path_web,
            targetModule: 'service/api',
            targetPackage: '${module}',
            fileName: '${entityNameLower}',
            fileType: 'ts',
            prefix: '',
            suffix: '',
            template: 'web/service/model.ts.tmpl',
            enable: false,
            statically: false,
            dependencies: ['controller'],
        },
        web_views_entity_index: {
            overridable: false,
            targetRoot: path_web,
            targetModule: 'views',
            targetPackage: '${module}/${entityNameHyphen}',
            fileName: 'index',
            fileType: 'vue',
            prefix: '',
            suffix: '',
            template: 'web/views/index.vue.tmpl',
            enable: false,
            statically: false,
            dependencies: ['controller'],
        },
        web_views_entity_components_model: {
            overridable: false,
            targetRoot: path_web,
            targetModule: 'views',
            targetPackage: '${module}/${entityNameHyphen}/components',
            fileName: 'model',
            fileType: 'ts',
            prefix: '',
            suffix: '',
            template: 'web/views/components/model.ts.tmpl',
            enable: false,
            statically: false,
            dependencies: ['controller'],
        },
        web_views_entity_components_tableActionModal: {
            overridable: false,
            targetRoot: path_web,
            targetModule: 'views',
            targetPackage: '${module}/${entityNameHyphen}/components',
            fileName: 'TableActionModal',
            fileType: 'vue',
            prefix: '',
            suffix: '',
            template: 'web/views/components/TableActionModal.vue.tmpl',
            enable: false,
            statically: false,
            dependencies: ['controller'],
        },
        web_views_entity_components_tableDetailModal: {
            overridable: false,
            targetRoot: path_web,
            targetModule: 'views',
            targetPackage: '${module}/${entityNameHyphen}/components',
            fileName: 'TableDetailModal',
            fileType: 'vue',
            prefix: '',
            suffix: '',
            template: 'web/views/components/TableDetailModal.vue.tmpl',
            enable: false,
            statically: false,
            dependencies: ['controller'],
        },
    },

};
